<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
   
</body>
<script>
    //写入5行4列的表格,将帖子数组中的数据填充到单元格去
    var arr = [
        ["第1条帖子","a","第2条帖子...","2011.02.14"],
        ["第2条帖子","b","第3条帖子...","2011.02.01"],
        ["第3条帖子","c","第4条帖子...","2011.02.23"],
        ["第4条帖子","d","第5条帖子...","2011.02.28"],
        ["第5条帖子","e","第1条帖子...","2021.03.05"]
    ];
    var arr1 = arr.sort();
var borderWidth = 1;
var tableWidth = 400;
var tableHeight = 400;
var i=0;
document.write("<table border='"+borderWidth+"' height='"+tableHeight+"' width='"+tableWidth+"'>");
function creatList(){
    for(var i=0;i<arr.length;i++){
        document.write("<tr>");
            for(var j=0;j<arr[0].length;j++){
                if(j==2){
                    arr[i][j]=arr[i][j].slice(0,5)+"...";
                }
                document.write("<td>");
                document.write(arr[i][j]);
                document.write("</td>");
            }
            document.write("<tr>");
    }
}
creatList(arr);
document.write("</table");
</script>
</html>